

import java.awt.*;
import javax.swing.*;

public class FormQuestao extends JPanel {
    private JLabel quest;
    private final ButtonGroup alt;
    private final JRadioButton a;
    private final JRadioButton b;
    private final JRadioButton c;
    private final JRadioButton d;
    private final JRadioButton e;
    private String correta;
    private String correcao;
    
    public FormQuestao(String q, String an, String bn, String cn, String dn, String en, String resp, String co) {
        this.setLayout(new BorderLayout());
        
        quest = new JLabel(q);
        JPanel p = new JPanel();
        p.add(quest);
        this.add(p, BorderLayout.CENTER);
        
        JPanel pAlt = new JPanel(new GridLayout(5,1));
        alt = new ButtonGroup();
        a = new JRadioButton(an);
        a.setActionCommand(A);
        alt.add(a);
        pAlt.add(a);
        b = new JRadioButton(bn);
        b.setActionCommand(B);
        alt.add(b);
        pAlt.add(b);
        c = new JRadioButton(cn);
        c.setActionCommand(C);
        alt.add(c);
        pAlt.add(c);
        d = new JRadioButton(dn);
        d.setActionCommand(D);
        alt.add(d);
        pAlt.add(d);
        e = new JRadioButton(en);
        e.setActionCommand(E);
        alt.add(e);
        pAlt.add(e);
        p = new JPanel();
        p.add(pAlt);
        this.add(p, BorderLayout.PAGE_END);
        
        correta = resp;
        correcao = co;
        
        this.setVisible(true);
    }
    
    public String corrige(){
        if(alt.getSelection().getActionCommand().equals(correta))
            return "Acertou!";
        else
            return correcao;
    }
    
    void setQuestao(String q, String an, String bn, String cn, String dn, String en, String resp, String co){
        quest.setText(q);
        a.setText(an);
        b.setText(bn);
        c.setText(cn);
        d.setText(dn);
        e.setText(en);
        correta = resp;
        correcao = co;
    }
   
    
    
    
    final static String A = "a";
    final static String B = "b";
    final static String C = "c";
    final static String D = "d";
    final static String E = "e";
}